package StudyCode.summary.mycollection;

import java.util.ArrayList;
import java.util.ListIterator;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class TraverseThroughArrayListInReverseDirectionUsingListIterator {
	public static void main(String[] args) {
		ArrayList aList = new ArrayList();
		aList.add("1");
		aList.add("2");
		aList.add("3");
		aList.add("4");
		aList.add("5");

		ListIterator listIterator = aList.listIterator();
		System.out.println("正向");
		while (listIterator.hasNext()) {
			System.out.println(listIterator.next());
		}
		System.out.println("反向");
		while (listIterator.hasPrevious()) {
			System.out.println(listIterator.previous());
		}
	}
}
